package com.xaicode.auth.service.impl;

import cn.hutool.core.util.StrUtil;
import com.xaicode.auth.base.BaseMpServiceImpl;
import com.xaicode.auth.entity.SysDictDetail;
import com.xaicode.auth.mapper.SysDictDetailMapper;
import com.xaicode.auth.security.domain.params.SysDictDetailQueryParam;
import com.xaicode.auth.service.ISysDictDetailService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictDetailServiceImpl extends BaseMpServiceImpl<SysDictDetailMapper, SysDictDetail> implements ISysDictDetailService {

    @Override
    public PageInfo<SysDictDetail> queryPage(SysDictDetailQueryParam query) {
        startPage(query);
        List<SysDictDetail> list = queryList(query);
        return PageInfo.of(list);
    }

    @Override
    public List<SysDictDetail> queryList(SysDictDetailQueryParam query) {
        LambdaQueryWrapper<SysDictDetail> lqw = Wrappers.lambdaQuery();
        lqw.eq(StrUtil.isNotBlank(query.getDictKey()), SysDictDetail::getDictKey, query.getDictKey());
        return list(lqw);
    }

}
